import { globalProps } from "../js/global"

export const handleOcr = (ocrResult)=>{
	if(ocrResult[0].category === "yuedu" || ocrResult[0].category === "xuanze"){
		//阅读题处理
		let returnResult = []
		for (let index = 0; index < 4; index++) {
			returnResult.push({
			  //阅读参数
			  "stuID": null,
			  "category": null,
			  "field": null,
			  "content": null,
			  "esID": null,
			  "cuoTiList": [],
			  //选择参数
			  "problem": null,
			  "answer": null,
			  "choice1": null,
			  "choice2": null,
			  "choice3": null,
			  "choice4": null,
			  "stuAnswer": null,
			  "aiComment": null,
			  "falseReason": null,
			})
		}
		for (let index = 0; index < 4; index++) {
			returnResult[index].stuID = globalProps.userInfo.id
			returnResult[index].content = ocrResult[index].content
			returnResult[index].category = ocrResult[index].category
			returnResult[index].esID = ocrResult[index].esID
			returnResult[index].cuoTiList = ocrResult[index].sonExercise
			returnResult[index].field = ocrResult[index].field
			
			returnResult[index].problem = ocrResult[index].problem
			returnResult[index].answer = ocrResult[index].answer
			returnResult[index].choice1 = ocrResult[index].choice1
			returnResult[index].choice2 = ocrResult[index].choice2
			returnResult[index].choice3 = ocrResult[index].choice3
			returnResult[index].choice4 = ocrResult[index].choice4
			returnResult[index].stuAnswer = ocrResult[index].stuAnswer
			returnResult[index].aiComment = ocrResult[index].aiComment
			returnResult[index].falseReason = ocrResult[index].falseReason
		}
		return returnResult
	}else if(ocrResult[0].category === "zuowen" || ocrResult[0].category === "fanyi"){
		//作文题处理
		console.log(ocrResult)
		let returnResult = []
		for (let index = 0; index < 4; index++) {
			returnResult.push({
			  "stuID": null,
			  "category": null,
			  "field": null,
			  "answer": null,
			  "content": null,
			  "esID": null,
			  "stuAnswer": null,
			  "falseReason": null,
			  "aiComment": null,
			  "cuoTiList": null,
			  "userComment": null
			})
		}
		for (let index = 0; index < 4; index++) {
			returnResult[index].category = ocrResult[index].category
			returnResult[index].stuID = globalProps.userInfo.id
			returnResult[index].answer = ocrResult[index].answer
			returnResult[index].content = ocrResult[index].content
			returnResult[index].esID = ocrResult[index].esID
			returnResult[index].field = ocrResult[index].field
		}
		return returnResult
	}
}